const userInfo = JSON.parse(localStorage.getItem('userInfo') || '{}')

// arr：原数组；str：匹配字段；val：当前节点字段
const getAllParent = (arr, str, val) => {
    for (let i = 0; i < arr.length; i++) {
        const item = arr[i]
        if (item[str] === val) {
            return []
        } else {
            if (item.children) {
                let res = []
                if ((res = getAllParent(item.children, str, val)) !== false) {
                    res.push(item)
                    return res
                }
            }
        }
    }
    return false
}

export { getAllParent }
